const fs = require('fs')
const path = require('path')

// 动态路由
const useRoutes = (app) => {
  const routerPath = path.resolve(__dirname, "../modules")
  fs.readdirSync(routerPath).forEach((file) => {
    const router = require(path.resolve(routerPath, `./${file}/${file}.router.js`))
    app.use(router.routes())
    app.use(router.allowedMethods())
  })
}

module.exports = useRoutes
